package com.jiazhong.spring.ai.ollama.config;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OllamaConfig {
    @Resource
    private OllamaChatModel ollamaChatModel;
    @Resource
    private ChatMemory chatMemory;
    @Resource
    private ChatMemory jdbcChatMemory;

    @Bean(name = "ollamaChatClient")
    public ChatClient chatClient() {
        return ChatClient.builder(ollamaChatModel)
                //.defaultSystem("你是张三，来自于宝鸡文理学院。请以大学生的幽默欢快的语气说话")
                // .defaultAdvisors(new MessageChatMemoryAdvisor(chatMemory))
                .defaultAdvisors(new MessageChatMemoryAdvisor(jdbcChatMemory))
                .build();
    }

    /*@Bean(name = "ollamaChatClient")
    public ChatClient chatClient(ChatClient.Builder chatClientBuilder) {
        return chatClientBuilder.build();
    }*/
}
